package com.vincent.common.utils;

import java.util.Random;

/**
 * 生成密码Key 的工具类
 */
public class PasswordKeyUtil {

    public static final int NUM = 50;

    /**
     * 获取密码key
     *
     * @return
     */
    public static String getRandomKey() {
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < NUM; i++) {
            int anInt = random.nextInt(79) + 48;
            sb.append((char) anInt);
        }
        return sb.toString();
    }

    /**
     * 获取加盐密码
     * @param salt Sha加密的盐
     * @param password 未加密的密码
     * @return 加盐后MD 5加密的密码
     */
    public static String getSaltPassword(String salt, String password) {
        return EncryptUtil.md5(salt + password);
    }
}
